package com.tkjt.pms.common.utils;

import java.util.Date;

public class TkIndexUtils {

	//TEMP......
	public final static String getIndexGroupNumber(String indexValueCode) {
		String type = indexValueCode.substring(1, 2);
		if ("G".equalsIgnoreCase(type)) {
			return "1";
		} else if ("C".equalsIgnoreCase(type)) {
			return "2";
		}
		return "";
	}

	public final static String getIndexCode(String indexValueCode) {
		String indexCode = indexValueCode.substring(2, 9);
		return indexCode;
	}

	public final static String getMonthType(String mirrorCode) {
		return "m" + mirrorCode.substring(6);
	}

	public final static String getMirrorCode(String whichYear, int whichMonth) {
		if (whichMonth < 10) {
			return "MC" + whichYear + "0" + whichMonth;
		} else {
			return "MC" + whichYear + whichMonth;
		}
	}

	public final static String getMirrorCode(Date date) {
		int year = EsDateUtils.getYears(date);
		String mStr = EsDateUtils.getLastMonthStr(date);
		if ("12".equals(mStr)) {
			year -= 1;
		}
		return "MC" + year + mStr;
	}

}
